<template>
  <div class="home">
    <Header />
    <div class="content">
      <div>测试请求数据：{{ data }}</div>
      <el-button
        type="danger"
        icon="el-icon-switch-button"
        style="float: right"
        @click="logOut()"
        >退出登录</el-button
      >
      <el-button
        type="primary"
        @click="stopBtnRepeat()"
        style="margin-top: 15px"
        v-stopBtnRepeat="5000"
        >阻止重复点击</el-button
      >
      <div style="margin-top: 15px">点击了{{ num }}次</div>
    </div>
  </div>
</template>

<script>
import { Header } from "@/components";
import { getTest } from "@/api/test";
// import { getInvalid } from '@/api/test'
export default {
  name: "Home",
  components: { Header },
  data() {
    return {
      data: {},
      num: 0,
    };
  },
  created() {
    console.log("store", this.$store);
    getTest().then((res) => {
      console.log("res", res);
      this.data = res;
    });
    // getInvalid().then(res => {
    //   console.log('res', res)
    //   this.data = res
    // })
  },
  mounted() {},
  methods: {
    async logOut() {
      this.$confirm("确定注销并退出系统吗？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        this.$store.dispatch("LogOut").then(() => {
          location.href = "/";
        });
      });
    },
    stopBtnRepeat() {
      this.num ++
    },
  },
};
</script>
<style lang="scss" scoped>
.home {
  width: 100%;
  height: 100%;
  background: url("../assets/big_bg.png") center no-repeat;
  background-size: 100% 100%;
  .content {
    width: calc(100% - 20px);
    height: calc(93% - 20px);
    padding: 10px;
    color: #fff;
  }
}
</style>
